<!DOCTYPE html>
<html>
<head>
<title>组织机构管理</title>
<link rel="stylesheet" th:href="@{/}+'layuiadmin/style/admin.css'" media="all">
<link rel="stylesheet" th:href="@{/}+'plugins/zTree/css/zTreeStyle/zTreeStyle.css'" media="all">
<script th:src="@{/}+'plugins/zTree/js/jquery.ztree.all.min.js'"></script>
</head>
<body>
<div class="layui-fluid">
  <div class="layui-card">  
    <div class="layui-card-body">
      <div class="layui-row">
    <ul id="treeDemo" class="ztree"></ul>
  	</div>
    </div>
  </div>
</div>

<script>
var openData1 = localStorage.getItem("tree1Selected");
var openIds1 = [];
if(openData1!=null){
		if(openData1!=null){
			openData1 = JSON.parse(openData1);
			var keys = Object.keys(openData1);
			for(x of keys){
				if(openData1[x].open==true){
					openIds1.push(x);
				}
			}
		}
}
var treeSetting = {
		async: {
			enable: true,
			url: "org/getFullOrgTree",
			autoParam:["id=pid"],
  		otherParam:{
  			openIds :openIds1.join(",")
  		}
		},
		view:{
			showTitle: true,
			selectedMulti : false
		},callback:{
			onExpand: function(event,treeId,node){
  			if(openData1==null){
  				openData1 = {};
  				openData1 = openData1[node.id] = {open:true};
  			}else{
  				openData1[node.id] = {open:true};
  			}
  			localStorage.setItem('tree1Selected',JSON.stringify(openData1));
  		},onCollapse:function(event,treeId,node){
  			if(openData1==null){
  				openData1 = {};
  				openData1[node.id] = {open: false};
  			}else{
  				openData1[node.id] = {open: false};
  			}
  			localStorage.setItem('tree1Selected',JSON.stringify(openData1));
      	}
		}
	};
	$.fn.zTree.init($("#treeDemo"), treeSetting);
	var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
layui.config({
    base:  'controller/system/org/'
  }).use('org', layui.factory('org')).use(['table', 'tree','form'], function(){
  var form = layui.form
  ,table = layui.table;

});
</script>
</body>